package com.example.demo.bingfa;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName Hearder
 * @Description TODO
 * Author yangqinglin
 * @Date 2021/2/10 18:03
 * @Version
 **/
@Slf4j(topic = "hearder")
public class Hearder {

    static final  Object lock=new Object();


    public static void main(String[] args) throws InterruptedException {
        new Thread(()->{
            synchronized (lock){
                try {
                    lock.wait(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                log.debug("其它代码...");

            }


        },"t2").start();

        new Thread(()->{
            synchronized (lock){
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                log.debug("其它代码...");

            }


        },"t1").start();


   Thread.sleep(3000);

   log.debug("唤醒lock上的其他线程");

   synchronized (lock){
//       lock.notify();
       lock.notifyAll();
   }
    }



}
